package com.yanqu.road.server.manager.activity.twins;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.server.manager.activity.twins.activity.CrossTwinsActivity;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CrossTwinsActivityGroup {

    private ActivityInfo activityInfo;

    private Map<Integer, CrossTwinsActivity> activityMap = new ConcurrentHashMap<>();

    public CrossTwinsActivityGroup(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public Map<Integer, CrossTwinsActivity> getActivityMap() {
        return activityMap;
    }

    public CrossTwinsActivity getActivity(int groupId) {
        if (!activityMap.containsKey(groupId)) {
            synchronized (activityMap) {
                if (!activityMap.containsKey(groupId)) {
                    CrossTwinsActivity activity = new CrossTwinsActivity(activityInfo, groupId);
                    activityMap.put(groupId, activity);
                }
            }
        }
        return activityMap.get(groupId);
    }




}
